package edu.iyte.ceng431.hw2.pos.model;

public class SaleLineItem implements ISaleLineItem {

	private int id;
	private Product product;
	private int quantity;
	private double unitPrice;

	public SaleLineItem(int id, Product product, int quantity) {
		super();
		this.id = id;
		this.product = product;
		this.unitPrice = product.getPrice();
		this.quantity = quantity;
	}

	public SaleLineItem( Product product, int quantity) {
		super();
		this.product = product;
		this.unitPrice = product.getPrice();
		this.quantity = quantity;
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public double getUnitPrice() {
		return unitPrice;
	}

	public void setUnitPrice(double unitPrice) {
		this.unitPrice = unitPrice;
	}

	@Override
	public double calculateSum() {
		return quantity * unitPrice;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Product getProduct() {
		return product;
	}
	
	public int getProductId()
	{
		return product.getId();
	}

}
